package com.example.demo.future;

import org.assertj.core.util.Lists;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.LongStream;

public class FutureTest2 {
    private ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();

    public static void main(String[] args) {
        Long start = System.currentTimeMillis();
        List<Future<List<String>>> list = new ArrayList<>();
        //Long l = LongStream.rangeClosed(0,10L).parallel().reduce(0,Long::sum);
        Long l = LongStream.rangeClosed(0,1000000000000L).parallel().reduce(0,Long::sum);
        Long end = System.currentTimeMillis();
        System.out.println(end - start);

    }

    public void futureTest(){
        /*Future<List<String>> future = new ThreadPoolTaskExecutor().submit(() -> {
           getFuture();
        });*/
    }

    public List<String> getFuture(){
        List<String> list = new ArrayList<>();
        for(int i=0; i<5; i++){
            list.add("" + i);
        }
        return list;
    }
}